﻿using Restaurant.entity;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Restaurant
{
    public partial class Login1 : Form
    {
        public Login1()
        {
            InitializeComponent();
        }

        private void Login1_Load(object sender, EventArgs e)
        {
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            this.Left = 0;
            this.Top = 0;
            SData.init();
            webBrowser1.ObjectForScripting = this;
            string urlPath = Environment.CurrentDirectory + "/login/index.html";
            urlPath = urlPath.Replace("%20", " ");
            webBrowser1.Navigate(urlPath);
            webBrowser1.IsWebBrowserContextMenuEnabled = false; //禁止右键
        }

        string[] userinfo;
        public void M(string n)
        {
            userinfo= n.Split(new string[] { "#" }, StringSplitOptions.RemoveEmptyEntries);
            if(userinfo.Length>1)
            if(userinfo[0].Equals("admin")&&userinfo[1].Equals("123456"))
            {
                MessageBox.Show("登录成功！");
                MainForm mf = new MainForm();
                mf.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("用户名或者密码错误！重新输入！");
            }
            //MessageBox.Show(userinfo[0]);
            //MessageBox.Show(userinfo[1]);
        }

        private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
            DialogResult dr = MessageBox.Show("确定要退出吗?", "退出系统", messButton);
            if (dr == DialogResult.OK)
            {
                Application.Exit();
            }
        }
    }
}
